﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using VOL.Domain.IServices.WarehouseManagement;
using VOL.Entity.DomainModels;
using VOL.Domain.Dtos;
using System.Threading.Tasks;

namespace VOL.WebApi.Controllers.WarehouseManagement
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InformController : ControllerBase
    {
        private readonly IInformService _informService;

        public InformController(IInformService informService)
        {
            _informService = informService;
        }

        /// <summary>
        /// 新增到货通知
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> AddInform([FromBody] Inform inform)
        {
            var result = await _informService.AddInformAsync(inform);
            return Ok(result);
        }

        /// <summary>
        /// 编辑到货通知
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> UpdateInform([FromBody] Inform inform)
        {
            var result = await _informService.UpdateInformAsync(inform);
            return Ok(result);
        }

        /// <summary>
        /// 批量删除到货通知
        /// </summary>
        [HttpGet]
        public async Task<IActionResult> DeleteInforms([FromQuery] int[] ids)
        {
            var result = await _informService.DeleteInformsAsync(ids);
            return Ok(result);
        }

        /// <summary>
        /// 查询到货通知列表（分页）
        /// </summary>
        [HttpGet]
        public async Task<IActionResult> QueryInformList([FromQuery] SelectInformDTO search)
        {
            var result = await _informService.QueryInformListAsync(search);
            return Ok(result);
        }
    }
}
